package control

import (
	"sync"
)

// AsyncControlMap 存储异步控制请求，以 key-value 对的形式
type AsyncControlMap struct {
	m sync.Map
}

func NewAsyncControlMap() *AsyncControlMap {
	return &AsyncControlMap{}
}

func (c *AsyncControlMap) Add(synInf string, asyncID string) {
	c.m.Store(synInf, asyncID)
}

func (c *AsyncControlMap) Get(synInf string) string {
	if load, ok := c.m.Load(synInf); ok {
		return load.(string)
	}
	return ""
}

func (c *AsyncControlMap) Delete(synInf string) {
	c.m.Delete(synInf)
}
